/**
 * 入参是函数,返回值是同样作用的函数,调用三次就失效了,三次后就没有调用效果
 */

function lazy(func, thresolad = 0) {
  let counter = 0;

  return function (...args) {
      const context = this;
      let result = null
    if (counter++ >= thresolad) {
      result = (function noop() {})();
    } else {
     result= func.apply(context, args);
    }
    return result;
  };
}

const fun1 = (name)=> console.log(name);

const res = lazy(fun1,3)

res(1)
res(2)
res(3)
res(4)
res(5)

